﻿using PayrollHR.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PayrollHR.Administration.Modules
{
    public partial class DatePickerRequied : BasePayrollAdministrationUserControl
    {
        #region Properties
        public bool ShowTime
        {
            get
            {
                return Convert.ToBoolean(ViewState["ShowTime"]);
            }
            set
            {
                ViewState["ShowTime"] = value;
            }
        }
        /// <summary>
        /// Gets or sets the select text.
        /// </summary>
        /// <value>
        /// The select text.
        /// </value>
        public string SelectText
        {
            get
            {
                return txtDateTime.Text;
            }
            set 
            {
                DateTime inputDate;                
                if (DateTime.TryParse(value, out inputDate))
                {
                    ajaxCalendar.SelectedDate = inputDate;
                }
            }
        }
        public DateTime? SelectedDate
        {
            get
            {
                DateTime inputDate;
                if (!DateTime.TryParseExact(txtDateTime.Text, this.Format, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.NoCurrentDateDefault, out inputDate))
                {
                    return null;
                }
                return inputDate;
            }
            set
            {
                ajaxCalendar.SelectedDate = value;
            }
        }

        public string Format
        {
            get
            {
                return ajaxCalendar.Format;
            }
            set
            {
                ajaxCalendar.Format = value;
            }
        }
        #endregion
    }
}